define(function(require,exports,module){
	var Grid = require("grid");
	
	module.exports = {
		initComponent: function(widget){
			var grid = new Grid({
				parentNode: ".J-grid",
				model: {
					url: "api/product/query",
					params: function(){
						return widget.model.prepQueryParams(widget);
					},
					columns: [{
						name: "name",
						label: "产品名称"
					},{
						name: "description",
						label: "备注"
					},{
						name: "operate",
						label: "操作",
						format: "button",
						formatparams: [{
							id: "edit",
							icon: "icon-edit",
							handler: function(index,data,rowEL){
								var form = widget.get("form");
								form.reset();
								form.setData(data);
								widget.toCard();
							}
						},{
							id: "remove",
							icon: "icon-remove",
							handler: function(index,data,rowEL){
								widget.service.del(data.pkProduct,function(){
									widget.get("grid").refresh();
								})
							}
						}]
					}]
				}
			});
			widget.set("grid",grid);
		}
	};
});